import time


def read2list(filename):
    file = open(filename, 'r')
    data = file.readlines()
    return data


def bubble_sort(arr):
    n = len(arr)
    i1 = 0
    b = True
    while(b):
        b = False
        for j in range(0, n - i1 - 1):
            if arr[j] > arr[j + 1]:
                arr[j], arr[j + 1] = arr[j + 1], arr[j]
                b = True
        i1 += 1
    return arr


all_m = [[[int(x) for x in "".join(read2list("m1_sorted.txt")).split()], "m1_sorted"],
         [[int(x) for x in "".join(read2list("m2_reverse.txt")).split()], "m2_reverse"],
         [[int(x) for x in "".join(read2list("m3_shuffle.txt")).split()], "m3_shuffle"]]
for i in range(3):
    t_start = time.time()
    m_s = bubble_sort(all_m[i][0])
    t_finish = time.time()
    print(all_m[i][1], round((t_finish - t_start) * 1000), "millisecond")
